# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        博智科技  
# Name:         demo1763
# Description:  gevent实现协程
# Author:       yzl
# Date:         2019-03-11
#-------------------------------------------------------------------------------

import gevent

def foo():
    print('running in foo')
    gevent.sleep(2)
    print('com back from bar in to foo')
def bar():
    print('running in bar')
    gevent.sleep(2)
    print('com back from foo in to bar')

gevent.joinall([      #创建线程并行执行程序，碰到IO就切换
    gevent.spawn(foo),
    gevent.spawn(bar),
])

